"off 更新时间：2016-03-30 12:15:21

" 定义快捷键的前缀，即 <Leader>
let mapleader="\\"
let mapleader="\<Space>"
" set macligatures
"set antialias
"set termencoding=utf-8
set fileencoding=utf-8
" https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.1/CascadiaCode.tar.xz
set guifont=CaskaydiaCove\ Nerd\ Font\ Propo:h10
set guifont=CaskaydiaCove\ Nerd\ Font\ 10
set guifont=Cascadia\ Code\ NF\ 10
"https://github.com/microsoft/cascadia-code/releases/download/v2404.23/CascadiaCode-2404.23.zip
" set guifont=CaskaydiaCove\ Nerd\ Font\ Propo:h12

let g:airline_powerline_fonts = 1
if exists("g:neovide")
  " let g:neovide_floating_blur_amount_x = 0.0
  " let g:neovide_floating_blur_amount_y = 0.0
  let g:neovide_cursor_animation_length=0.02  
  let g:neovide_cursor_vfx_mode = ""
  " let g:neovide_cursor_trail_length=0.4
  " let g:neovide_cursor_vfx_mode = "sonicboom"
  set guifont=DroidSansMono\ Nerd\ Font:h
  set guifont=DejaVuSansMono\ Nerd\ Font:h12
  " Put anything you want to happen only in Neovide here
endif
if has("gui_running")
  set guifont=CaskaydiaCove\ Nerd\ Font\ 10
  " if g:os == "Darwin"
  "   set guifont=DroidSansMono\ Nerd\ Font:h
  "   set guifont=DejaVuSansMono\ Nerd\ Font:h12
  " endif
  if has("mac")
    set guifont=DroidSansMono\ Nerd\ Font:h
    set guifont=DejaVuSansMono\ Nerd\ Font:h12
  endif

endif
if has('nvim-0.5')
  let g:uselsp = 1
  let g:use_nvim5 = 1
else
  let g:use_nvim5 = 0
endif

    " font = wezterm.font("DroidSansMono Nerd Font"),
set undodir=~/.config/.nvim/undo
" Other configuration
if exists('g:glrnvim_gui')
    "do something
endif
if exists('g:nvui')
  NvuiCmdFontFamily Jetbrains Mono
  NvuiCmdFontSize 25.0
  NvuiScrollAnimationDuration 0.2
endif
execute 'source' fnamemodify(expand('<sfile>'), ':h').'/basic.vim'
"{{{{
if has('nvim-0.5')
  call plug#begin('~/nvim.plugin')
else
  call plug#begin('~/vim.plugin')
endif

Plug  'kyazdani42/nvim-web-devicons' " Recommended (for coloured icons)
Plug  'ryanoasis/vim-devicons'
Plug  'ojroques/vim-oscyank', {'branch': 'main'}
vnoremap <leader>yy :OSCYankRegister<CR>
autocmd TextYankPost * if v:event.operator is 'y' && v:event.regname is '' | execute 'OSCYankRegister "' | endif
let g:oscyank_max_length = 1000000




function! s:plugin_colortheme() abort
  Plug 'challenger-deep-theme/vim', { 'as': 'challenger-deep' }

  "This plugin will display the colour which corresponds to text on the screen.
  if has('nvim-0.5')
    Plug 'norcalli/nvim-colorizer.lua' 
    " Plug 'yamatsum/nvim-cursorline'
    let g:cursorline_timeout = 200
  else
    Plug 'RRethy/vim-hexokinase'
  endif
  " Plug 'arzg/vim-colors-xcode'
  Plug 'sainnhe/edge'
  Plug 'vv9k/bogster'
  if exists('g:uselsp')
    Plug 'tanvirtin/monokai.nvim'
    Plug 'folke/lsp-colors.nvim'
    Plug 'ray-x/aurora'
    Plug 'dracula/vim'
    " Plug 'sainnhe/gruvbox-material'
    " Plug 'tanvirtin/monokai.nvim'
    " Plug 'bluz71/vim-nightfly-guicolors'
    " Plug 'Mofiqul/vscode.nvim'

    let g:material_style = 'lighter'
    " Plug 'marko-cerovac/material.nvim'
    " Plug 'nxvu699134/vn-night.nvim'
    " Plug 'christianchiarulli/nvcode-color-schemes.vim'
    " Plug 'lourenci/github-colors', { 'branch': 'main' }
    " Plug 'ray-x/aurora'      " for Plug user
    Plug 'sainnhe/sonokai'
    Plug 'RRethy/base16-nvim'
    Plug 'tjdevries/colorbuddy.nvim'
    Plug 'klooj/noogies'
    " Plug 'folke/tokyonight.nvim', { 'branch': 'main' }
    Plug 'glepnir/zephyr-nvim'
    " Plug 'olimorris/onedarkpro.nvim'
    " Plug 'tomasiser/vim-code-dark'
  else
    Plug  'flazz/vim-colorschemes'
    Plug  'jacoborus/tender.vim'
    Plug  'sainnhe/lightline_foobar.vim'
    Plug  'morhetz/gruvbox'
    Plug  'kyoz/purify', { 'rtp': 'vim' }
  endif

endfunction
call s:plugin_colortheme() 


"Plug 'qpkorr/vim-bufkill'
" Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install'  }
Plug 'ellisonleao/glow.nvim'


function! s:plugin_keyboard() abort
  " Plug  'vim-scripts/a.vim'
  command! A  :ClangdSwitchSourceHeader
  Plug 'skywind3000/asyncrun.vim'
  Plug 'rhysd/accelerated-jk'
  nmap j <Plug>(accelerated_jk_gj)
  nmap k <Plug>(accelerated_jk_gk)

  if has('nvim-0.5')
    Plug 'folke/which-key.nvim'
  else
    Plug 'liuchengxu/vim-which-key'
  endif
  let g:which_key_map =  {}
  Plug 't9md/vim-choosewin'
  nmap  -  <Plug>(choosewin)
endfunction
call s:plugin_keyboard() 








function! s:plugin_search_navigation() abort
  " Plug 'dyng/ctrlsf.vim'
  Plug 'mhinz/vim-startify'
  Plug 'itchyny/vim-gitbranch'
  Plug 'romainl/vim-qf'
  if has('nvim-0.5')
    "Plug 'stevearc/stickybuf.nvim'
    autocmd BufEnter * if &winfixwidth || &winfixheight | silent! PinBuffer | endif
    Plug 'ThePrimeagen/refactoring.nvim'
    Plug 'sindrets/diffview.nvim'
    Plug 'kevinhwang91/nvim-bqf'
    " Plug 'fcpg/vim-kickfix'
    Plug 'nvim-lua/popup.nvim'
    Plug 'nvim-lua/plenary.nvim'
    Plug 'tami5/sql.nvim'	
    Plug 'AckslD/nvim-neoclip.lua'
    Plug 'nvim-telescope/telescope.nvim'
    Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' }
    Plug 'nvim-telescope/telescope-fzy-native.nvim'
    Plug 'nvim-telescope/telescope-project.nvim'
    Plug 'nvim-telescope/telescope-frecency.nvim'
    Plug 'nvim-telescope/telescope-dap.nvim'
    Plug 'HUAHUAI23/telescope-dapzzzz'
    Plug 'LinArcX/telescope-command-palette.nvim'
    Plug 'nvim-telescope/telescope-live-grep-args.nvim'
    Plug 'nvim-telescope/telescope-symbols.nvim'
    Plug 'camspiers/snap'
    " Plug 'rmagatti/auto-ession'
    " Plug 'rmagatti/session-lens'
    autocmd User TelescopePreviewerLoaded setlocal number relativenumber wrap list

    " Plug 'nvim-telescope/telescope-media-files.nvim'
    Plug 'BurntSushi/ripgrep'
    let g:use_plugin_telescope=1
    command! -nargs=0 ShowProject :Telescope projects
    command! -nargs=0 AG :Telescope live_grep_args
    command! -nargs=0 AW :lua require('telescope-live-grep-args.shortcuts').grep_word_under_cursor()
    " noremap <C-P> :<C-u>Telescope  find_files<CR>
    noremap <leader>wk <cmd>Telescope  projects<CR>
    nnoremap <silent> <space><space> :<C-u>Telescope<CR>
    nnoremap <silent> <space>c :<C-u>Telescope command_palette<CR>
    Plug 'liuchengxu/vim-clap', { 'do': ':Clap install-binary' }
  else
    Plug 'liuchengxu/vim-clap', { 'do': ':Clap install-binary' }
    noremap <C-P> :<C-u>FZF<CR>
  endif

  Plug 'junegunn/fzf', {'dir': '~/.fzf','do': './install --all'}
  Plug 'junegunn/fzf.vim' " needed for previews
  " nnoremap <silent> <space>bb  :<C-u>Buffers<cr>

  if !exists('g:uselsp')
    Plug 'antoinemadec/coc-fzf', {'branch': 'release'}
  endif

  " Plug 'brooth/far.vim'
  Plug 'nvim-lua/plenary.nvim'
  Plug 'windwp/nvim-spectre'
  " nnoremap <leader>sF :lua require('spectre').open()<CR>
  " nnoremap <leader>sw <cmd>lua require('spectre').open_visual({select_word=true})<CR>
  Plug  '907th/vim-auto-save'
  let g:auto_save = 1  " enable AutoSave on Vim startup
endfunction
call s:plugin_search_navigation() 







function! s:plugin_shell() abort
  Plug 'akinsho/toggleterm.nvim'
  Plug 'voldikss/vim-floaterm'
endfunction
call s:plugin_shell()

function! s:plugin_ui() abort
  " Plug 'yssl/QFEnter'
  Plug 'stevearc/qf_helper.nvim'
  "加上/解开注释, 智能判断
  " >>
  " 工程文件浏览
  " Plug 'kevinhwang91/rnvimr', {'do': 'make sync'}
  " let g:rnvimr_ex_enable = 1
  if exists('g:use_vwm')
    Plug 'paroxayte/vwm.vim'
    let s:def_layt = {
          \  'name': 'default',
          \  'set_all': ['nonu', 'nornu'],
          \  'right':
          \  {
          \    'v_sz': 33,
          \    'init': ['Tagbar'],
          \    'bot':
          \    {
          \      'init': ['NERDTree'],
          \    }
          \  }
          \}

    if !exists('g:vwm#layouts')
      let g:vwm#layouts = [s:def_layt]
    endif
  endif



  if exists('g:use_wm')
    Plug  'vim-scripts/winmanager'
    Plug  'fholgado/minibufexpl.vim'
    let g:miniBufExplAutoStart = 0
    Plug  'vim-scripts/taglist.vim'
    let Tlist_Show_One_File=1
  endif


  let g:useairline_tabline = 0
  Plug  'preservim/nerdtree'
  let g:NERDTreeWinPos = "right"
  Plug 'francoiscabrol/ranger.vim'
  Plug 'rbgrouleff/bclose.vim'
  if has('nvim-0.5')
    " Plug 'stevearc/stickybuf.nvim'
    let g:useairline = 0
    let g:uselualine = 1
    let g:usestatusline = 0
    if g:useairline == 1
      Plug 'vim-airline/vim-airline'
      Plug 'vim-airline/vim-airline-themes'
    endif
    if g:usestatusline == 1
      Plug 'beauwilliams/statusline.lua'
    endif
    if g:uselualine == 1 
      Plug 'nvim-lualine/lualine.nvim'
    endif
    " Plug 'stevearc/stickybuf.nvim'
    "Plug 'sidebar-nvim/sidebar.nvim'
    let g:chadtree_settings={'view.open_direction':'right','theme.text_colour_set':'nerdtree_syntax_dark'}

    " Plug 'kyazdani42/nvim-tree.lua'
    Plug 'nvim-tree/nvim-tree.lua'
    Plug 'nvim-neo-tree/neo-tree.nvim'
    Plug 'MunifTanjim/nui.nvim'
    Plug '3rd/image.nvim'
    nnoremap xf :Neotree float reveal_file=<cfile> reveal_force_cwd<cr>
    " cokeline
    let g:use_barbar = 0
    let g:use_cokeline= 0
    let g:use_bufferline= 1

    if g:use_cokeline
      Plug 'noib3/cokeline.nvim'
    endif
    if g:use_bufferline
      Plug 'akinsho/bufferline.nvim'
      nnoremap <silent>t :BufferLinePick<CR>
    endif
    if g:use_barbar
      Plug 'romgrk/barbar.nvim'
      nnoremap <silent>t :BufferPick<CR>
    endif

  else
    let g:useairline = 1
    let g:useairline_tabline = 1
    if g:useairline
      Plug 'vim-airline/vim-airline'
      Plug 'vim-airline/vim-airline-themes'
    endif
  endif


  function! BufferDelete()
    let s:total_nr_buffers = len(filter(range(1, bufnr('$')), 'buflisted(v:val)'))

    if s:total_nr_buffers == 1
      bdelete
      echo "Buffer deleted. Created new buffer."
    else
      bprevious
      bdelete #
      echo "Buffer deleted."
    endif
  endfunction

  " command! -nargs=0 Bw :bdelete
  command! -bang -complete=buffer -nargs=? Bw call BufferDelete()
endfunction
call s:plugin_ui()

"{{
"debugger 
function! s:plugin_dev()
  augroup WrapLineInTeXFile
    autocmd!
    autocmd FileType log setlocal wrap
  augroup END
  let $OPENAI_API_KEY="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"
  Plug 'akinsho/flutter-tools.nvim'
  Plug 'antoyo/vim-licenses'
  " Plug 'jackMort/ChatGPT.nvim'
  " Plug 'dpayne/CodeGPT.nvim'
  Plug 'MunifTanjim/nui.nvim'
  Plug 'mtdl9/vim-log-highlighting'
  "Plug 'cdelledonne/vim-cmake'
  let g:cmake_build_dir_location = 'build'

  " Plug 'ilyachur/cmake4vim'
  " let g:cmake_build_type = '-DCMAKE_BUILD_TYPE'
  Plug 'ellisonleao/glow.nvim'
  " Plug 'christoomey/vim-tmux-navigator'
  "Plug  'aserowy/tmux.nvim'
  Plug 'prettier/vim-prettier', { 'do': 'yarn install --frozen-lockfile --production' }
  vnoremap <leader>en :!python3 -c 'import sys; from urllib import parse; print(parse.urlencode(sys.stdin.read().strip()))'<cr>
  vnoremap <leader>de :!python3 -c 'import sys; from urllib import parse; print(parse.unquote(sys.stdin.read().strip()))'<cr>

  "Plug 'inkarkat/vim-LogViewer'
  "Plug 'andreshazard/vim-logreview'
  Plug 'wfxr/minimap.vim'
  let  g:minimap_git_colors = 1
  let   g:minimap_width = 10
  function! FloatWindowMinimapHack() abort
    if winnr() == bufwinnr('-MINIMAP-')
      exe "wincmd w"
    endif
  endfunction
  autocmd WinEnter * call FloatWindowMinimapHack()

  let g:use_treesitter = 0
  Plug 'lukas-reineke/indent-blankline.nvim',  { 'as': 'ibl' }
  Plug 'kana/vim-textobj-user'
  if has('nvim-0.5')
  else
    Plug 'vim-scripts/DoxygenToolkit.vim'
  endif

  Plug  'kana/vim-textobj-function'
  if has('nvim-0.5')
    Plug 'sakhnik/nvim-gdb', { 'do': ':!./install.sh' }
    " Plug 'kevinhwang91/nvim-ufo' 
    Plug 'kevinhwang91/promise-async'
    Plug 'Tastyep/structlog.nvim'
    if has('nvim-0.9')
      let g:use_treesitter = 1
      Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}  " We recommend updating the parsers on update
      "Plug 'nvim-treesitter/nvim-treesitter-refactor'
      Plug 'nvim-treesitter/nvim-treesitter-textobjects'
    endif
    " Plug 'SmiteshP/nvim-gps'
    "
    Plug 'fgheng/winbar.nvim'
    Plug 'SmiteshP/nvim-navic'
    " Plug 'ray-x/guihua.lua', {'do': 'cd lua/fzy && make' }
    " Plug 'ray-x/navigator.lua'
    " Plug 'm-pilia/vim-ccls'
  endif


  function! s:plugin_debugger()
    if has('nvim-0.5')
      "Plug  'klen/nvim-test'
      Plug 'jbyuki/one-small-step-for-vimkind'
      "Plug 'Joakker/lua-json5'
      let g:use_dap= 0
      if g:use_dap==1
        Plug 'nvim-neotest/nvim-nio'
        Plug 'Joakker/lua-json5',{'do': './install.sh'}
        "Plug 'Pocco81/DAPInstall.nvim'
        Plug 'mfussenegger/nvim-dap'
        Plug 'mfussenegger/nvim-dap-python'
        Plug 'leoluz/nvim-dap-go'
        Plug 'rcarriga/nvim-dap-ui'
        Plug 'rafcamlet/nvim-luapad'
        command! -nargs=0 DapUI :lua  require("dapui").toggle()
      else
        let g:vimspector_enable_mappings = 'VISUAL_STUDIO'
        Plug 'puremourning/vimspector' 
      endif
    else
      let g:vimspector_enable_mappings = 'VISUAL_STUDIO'
      Plug 'puremourning/vimspector'
    endif
  endfunction

  function! s:plugin_snips() abort
    "Plug  'SirVer/ultisnips'
    Plug  'honza/vim-snippets'
    let g:UltiSnipsExpandTrigger="<c-t>"
  endfunction

  function! s:plugin_comment()
    if has('nvim-0.5')
      "Plug 'numToStr/Comment.nvim'
      "Plug 'kylechui/nvim-surround'
      Plug 'preservim/nerdcommenter'
      Plug 'tpope/vim-surround'
      " Plug 'windwp/nvim-autopairs'
    else
      Plug 'preservim/nerdcommenter'
      Plug 'tpope/vim-surround'
    endif
  endfunction

  function! s:plugin_git() abort
    let g:use_gitsigns = 0
    let g:use_vgit = 0
    let g:use_gitgutter = 0
    if has('nvim-0.5')
      let g:use_gitsigns = 1
      let g:use_vgit = 0
      Plug 'tanvirtin/vgit.nvim'
    else
      let g:use_gitgutter = 1
    endif

    let g:use_gitgutter = 1
    if g:use_gitgutter
      Plug  'airblade/vim-gitgutter'
    endif 
    if g:use_gitsigns
      Plug 'lewis6991/gitsigns.nvim'
      "Plug 'APZelos/blamer.nvim'

      Plug 'f-person/git-blame.nvim'
      " Plug 'tveskag/nvim-blame-line'
      " autocmd BufEnter * EnableBlameLine
    endif

    Plug  'tpope/vim-fugitive'
    augroup user_fugitive_plugin
      autocmd!
      autocmd FileType fugitiveblame normal A
    augroup END

    Plug  'neoclide/vim-easygit'
    let g:easygit_enable_command = 1
    "}}}
  endfunction

  function! s:plugin_tags() abort
    " Plug 'chentoast/marks.nvim'
    Plug 'MattesGroeger/vim-bookmarks'
    " let g:bookmark_save_per_working_dir = 1
    let g:bookmark_auto_save = 1
    Plug 'majutsushi/tagbar'
    let g:tagbar_position = 'topleft vertical'
    " let g:tagbar_position = 'botright vertical'
    " Focus the panel when opening it
    let g:tagbar_autofocus = 1
    " Highlight the active tag
    let g:tagbar_autoshowtag = 1
    "gtags-------------------------
    "Plug  'gtags.vim'
    Plug 'vim-scripts/gtags.vim'
    " Plug 'ludovicchabant/vim-gutentags'
    " Plug 'skywind3000/gutentags_plus'
    let g:gutentags_define_advanced_commands = 1

    " enable gtags module
    let g:gutentags_modules = ['ctags', 'gtags_cscope']
    " config project root markers.
    let g:gutentags_project_root = ['.root']
    " generate datebases in my cache directory, prevent gtags files polluting my project
    let g:gutentags_cache_dir = expand('~/.cache/tags')
    let g:gutentags_plus_switch = 1
    let g:gutentags_plus_nomap = 1

    noremap <silent> <leader>js :GscopeFind s <C-R><C-W><cr>
    noremap <silent> <leader>jg :GscopeFind g <C-R><C-W><cr>
    noremap <silent> <leader>jc :GscopeFind c <C-R><C-W><cr>
    noremap <silent> <leader>jt :GscopeFind t <C-R><C-W><cr>
    noremap <silent> <leader>je :GscopeFind e <C-R><C-W><cr>
    noremap <silent> <leader>jf :GscopeFind f <C-R>=expand("<cfile>")<cr><cr>
    noremap <silent> <leader>ji :GscopeFind i <C-R>=expand("<cfile>")<cr><cr>
    noremap <silent> <leader>jd :GscopeFind d <C-R><C-W><cr>
    noremap <silent> <leader>ja :GscopeFind a <C-R><C-W><cr>
    noremap <silent> <leader>jz :GscopeFind z <C-R><C-W><cr>
    "
    if !exists('g:uselsp')
      Plug 'liuchengxu/vista.vim'
    else
      " Plug 'liuchengxu/vista.vim'
      Plug 'anstadnik/symbols-outline.nvim'
    endif
  endfunction

  function! s:plugin_lsp() abort
    let g:coc_global_extensions = [
            \ 'coc-marketplace',
            \ 'coc-floaterm',
            \ 'coc-tabnine',
            \ 'coc-pyright',
            \ 'coc-git',
            \ 'coc-go',
            \ 'coc-protobuf',
            \ 'coc-sh',
            \ 'coc-lists',
            \ 'coc-clangd',
            \ 'coc-terminal',
            \ ]
    "coc_nvim
    "
    if !exists('g:uselsp')
      Plug 'neoclide/coc.nvim', {'branch': 'release'}
      inoremap <silent><expr> <cr> coc#pum#visible() && coc#pum#info()['index'] != -1 ? coc#pum#confirm() :
            \ "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
      nnoremap <silent> <space>el  :<C-u>CocList extensions<cr>
      nnoremap <silent> <Leader>cF :<C-u>CocFix<CR>
      let g:use_coc = 1
    else
      Plug 'ranjithshegde/ccls.nvim'
      " Plug 'ldelossa/litee.nvim'
      " Plug 'ldelossa/litee-symboltree.nvim'
      " Plug 'ldelossa/litee-filetree.nvim'
      " Plug 'ldelossa/litee-calltree.nvim'
      Plug 'jiangmiao/auto-pairs'
      Plug 'danymat/neogen'
      " Plug 'jubnzv/virtual-types.nvim'
      Plug 'haringsrob/nvim_context_vt'
      Plug 'stevearc/aerial.nvim'

      Plug 'ahmedkhalf/project.nvim'
      Plug 'neovim/nvim-lspconfig'
      Plug 'nvim-lua/lsp-status.nvim'
      Plug 'SmiteshP/nvim-navic'
      Plug 'williamboman/mason-lspconfig.nvim'
      "Plug 'kabouzeid/nvim-lspinstall'
      Plug 'williamboman/mason.nvim', { 'do': ':MasonUpdate' }



      Plug 'ray-x/lsp_signature.nvim'



      let g:use_nvim_comp=1
      let g:use_coc_comp=0
      let g:use_coq_nvim=0
      if g:use_coc_comp
        Plug 'neoclide/coc.nvim', { 'branch': 'master', 'do': 'yarn install --frozen-lockfile' }
      endif


      
      " Plug 'github/copilot.vim'
      if g:use_nvim_comp
        Plug 'hrsh7th/nvim-cmp'

        Plug 'hrsh7th/cmp-nvim-lsp'
        " Plug 'hrsh7th/cmp-copilot'
        Plug 'hrsh7th/cmp-buffer'
        Plug 'hrsh7th/cmp-path'
        Plug 'hrsh7th/cmp-cmdline'
        Plug 'tzachar/cmp-tabnine', { 'do': './install.sh' }


        Plug 'hrsh7th/cmp-vsnip'
        Plug 'hrsh7th/vim-vsnip'

        "Plug 'quangnguyen30192/cmp-nvim-ultisnips'
        Plug 'onsails/lspkind-nvim'
      endif

      if g:use_coq_nvim == 1
        Plug 'ms-jpq/coq_nvim', {'branch': 'coq'}
        Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'}
        Plug 'ms-jpq/coq.thirdparty', {'branch': '3p'}
        let g:coq_settings = { 'auto_start': v:true ,'clients.tabnine.enabled':v:true}
      endif


      Plug 'gfanto/fzf-lsp.nvim'

      Plug 'sbdchd/neoformat'

      Plug 'folke/trouble.nvim'
      set completeopt=menu,menuone,noselect
      command! -nargs=0 Format :lua vim.lsp.buf.format()
      command! -nargs=0 FormatRange :lua vim.lsp.buf.format()
      command! -nargs=0 CodeAction :lua vim.lsp.buf.code_action()
    endif
  endfunction
  
  command! -nargs=0 VT :belowright vsplit|terminal

  function! ClearTerminal()
    let s:scroll_value = 3000
    set scrollback=1
    let &g:scrollback=1
    echo &scrollback
    call feedkeys("\i")
    call feedkeys("clear\<CR>")
    call feedkeys("\<C-\>\<C-n>")
    call feedkeys("\i")
    sleep 100m
    let &scrollback=s:scroll_value
  endfunction
  command! -nargs=0 Clear :call ClearTerminal()

  function! s:plugin_js() abort
    "------------------------ VIM TSX ------------------------
    " by default, if you open tsx file, neovim does not show syntax colors
    " vim-tsx will do all the coloring for jsx in the .tsx file
    Plug 'ianks/vim-tsx'
    "------------------------ VIM TSX ------------------------
    " by default, if you open tsx file, neovim does not show syntax colors
    " typescript-vim will do all the coloring for typescript keywords
    Plug 'leafgarland/typescript-vim'
    Plug  'ap/vim-css-color'
  endfunction



  autocmd BufRead,BufNewFile *.metal :set ft=cpp


  function! s:plugin_objc() abort
    "objective-c
    " Plug 'Raimondi/delimitMate'
    " Plug 'eraserhd/vim-ios'
    " Plug 'jgoulah/cocoa.vim'           " method list, documentation
    autocmd BufRead,BufNewFile *.mm :set ft=objc
  endfunction


  call s:plugin_js()
  call s:plugin_objc()


  call s:plugin_lsp() 
  call s:plugin_tags()
  call s:plugin_git() 
  call s:plugin_comment()
  call s:plugin_snips() 
  call s:plugin_debugger()
endfunction
call s:plugin_dev()
"}}
"


" nnoremap <leader>S :lua require('spectre').open()<CR>
" nnoremap <leader>sw viw:lua require('spectre').open_file_search({select_word=true})<cr>
"nnoremap <leader>ca :Telescope lsp_code_actions<CR>


"Tagbar........................................................................................
"{{{



call plug#end()
"}}}}



"nnoremap <silent> <space><space> :<C-u>CocFzfList<CR>
" set timeoutlen=500




" by default .ts file are not identified as typescript and .tsx files are not
" identified as typescript react file, so add following
au BufNewFile,BufRead *.ts setlocal filetype=typescriptinit
au BufNewFile,BufRead *.tsx setlocal filetype=typescript.tsx



"{{{  colorscheme
"colorscheme 1989 
"set background=dark    " Setting dark mode
"colorscheme purify
"autocmd vimenter * ++nested colorscheme gruvbox
"colorscheme Atelier_CaveDark 
"colorscheme molokai
"colorscheme gruvbox
" colorscheme edge
if has('nvim-0.5')
  set termguicolors
  let g:vscode_style = "light"
  let g:tokyonight_style = "day"
  colorscheme base16-snazzy
  "colorscheme vn-night
  "colorscheme zephyr
  " colorscheme edge 
  " colorscheme bogster
else
  colorscheme gruvbox
endif
"}}}
"



" let path = expand('%:p:h')
" let root =stdpath('config')
if has('nvim-0.5')
  lua require('keymap/whichkey')
else
  execute 'source' fnamemodify(expand('<sfile>'), ':h').'/vim/whichkey.vim'
endif


execute 'source' fnamemodify(expand('<sfile>'), ':h').'/vim/search/search.vim'
execute 'source' fnamemodify(expand('<sfile>'), ':h').'/vim/ui/tab.vim'
execute 'source' fnamemodify(expand('<sfile>'), ':h').'/vim/explorer/explorer.vim'
execute 'source' fnamemodify(expand('<sfile>'), ':h').'/vim/explorer/shell.vim'
execute 'source' fnamemodify(expand('<sfile>'), ':h').'/vim/dev/vsc.vim'

if !exists('g:uselsp')
  execute 'source' fnamemodify(expand('<sfile>'), ':h').'/vim/dev/dev.vim'
else
  set termguicolors
  lua require('core')
  execute 'source' fnamemodify(expand('<sfile>'), ':h').'/vim/dev/module-vista.vim'
  nnoremap <silent> <Leader>i :<C-u>SymbolsOutline<CR>
endif




function! s:load_quitmap() abort
  function! QuitVim() abort
    if empty(expand('%:t'))
      execute ":q"
    else
      execute ":wq!"
    endif
  endfunction
  " Quit
  "nnoremap <leader>qq :call QuitVim()<CR>
  nnoremap <leader>qw <esc>:q!<CR>
endfunction
"call s:load_quitmap()

noremap <C-H> :SClose<CR>
noremap <Leader>y "*y
noremap <Leader>p "*p
noremap <Leader>Y "+y
noremap <Leader>P "+p

nnoremap <D-v> a<C-r>+<Esc>
inoremap <D-v> <C-r>+
cnoremap <D-v> <C-r>+

" :hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
augroup CursorLine
  au!
  au VimEnter,WinEnter,BufWinEnter * setlocal cursorline
  au VimEnter,WinEnter,BufWinEnter * setlocal cursorcolumn
  au WinLeave * setlocal nocursorline
  au WinLeave * setlocal nocursorcolumn
  if has('nvim-0.5')
    :hi CursorLine   cterm=NONE ctermbg=DarkGreen  ctermfg=white guibg=DarkGreen
    :hi CursorColumn   cterm=NONE ctermbg=DarkGreen ctermfg=white guibg=DarkGreen gui=NONE
  endif
  :hi CursorLine   cterm=NONE ctermbg=DarkGreen  ctermfg=white guibg=DarkGreen
  " au VimEnter,WinEnter,BufWinEnter noremap <C-H> :SClose<CR>
augroup END
au BufRead,BufNewFile *.metal setfiletype metal
hi FocusedSymbol term=bold cterm=bold ctermbg=red ctermfg=white gui=bold guibg=red guifg=white
"vmap <leader>cf <cmd>:lua vim.lsp.buf.range_formatting()<CR>
"xmap <leader>cf <cmd>:lua vim.lsp.buf.range_formatting()<CR>


command! CopyBuffer let @+ = expand('%:p')
" set foldmethod=expr
" set foldexpr=nvim_treesitter#foldexpr()
"minimap minimap
function! FloatWindowMinimapHack() abort
    let mmwinnr = bufwinnr('-MINIMAP-')
    if mmwinnr == -1
        return
    endif
    if winnr() == mmwinnr
        " Go to the other window
        execute 'wincmd t'
    endif
endfunction
autocmd WinEnter <buffer> call FloatWindowMinimapHack()
